package com.onekbase.demo.mybatis;

import com.onekbase.demo.mybatis.mapper.SysConfigMapper;
import com.onekbase.demo.mybatis.model.SysConfig;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class D03MapperMain {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory factory = builder.build(inputStream);
        try (SqlSession session = factory.openSession()) {
            SysConfigMapper mapper = session.getMapper(SysConfigMapper.class);
            SysConfig sc=mapper.selectConfig2("key.hello");
            System.out.println(sc);
        }
    }
}
